Component({
  data: {
    selected: 0,
    list: [
      {
        pagePath: "/pages/home/home",
        iconPath: "https://publicminprogram.oss-cn-heyuan.aliyuncs.com/assets/icons/home_origin.png",
        selectedIconPath: "https://publicminprogram.oss-cn-heyuan.aliyuncs.com/assets/icons/home_origin.png",
        text: "首页"
      },
      {
        pagePath: "/pages/design/design",
        iconPath: "https://publicminprogram.oss-cn-heyuan.aliyuncs.com/assets/icons/design_origin.png",
        selectedIconPath: "https://publicminprogram.oss-cn-heyuan.aliyuncs.com/assets/icons/design_origin.png",
        text: "画图"
      },
      {
        pagePath: "/pages/order/order",
        iconPath: "https://publicminprogram.oss-cn-heyuan.aliyuncs.com/assets/icons/order_origin.png",
        selectedIconPath: "https://publicminprogram.oss-cn-heyuan.aliyuncs.com/assets/icons/order_origin.png",
        text: "订单"
      },
      {
        pagePath: "/pages/profile/profile",
        iconPath: "https://publicminprogram.oss-cn-heyuan.aliyuncs.com/assets/icons/profile_origin.png",
        selectedIconPath: "https://publicminprogram.oss-cn-heyuan.aliyuncs.com/assets/icons/profile_origin.png",
        text: "我的"
      }
    ]
  },

  methods: {
    switchTab(e: WechatMiniprogram.BaseEvent) {
      const data = e.currentTarget.dataset;
      const url = data.path;
      
      // 更新选中项并跳转页面
      this.setData({
        selected: data.index
      });
      wx.switchTab({ url });
    }
  }
});
